<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    /*1.修改length长度来进行新增数组元素，新增的数组元素是空的数组元素*/
    var arr1 = ['red','green','yellow'];
    arr1.length = 5;
    console.log(arr1);
    /*修改索引号来追加数组元素，不能直接给数组名赋值否则里面的数组元素都会没*/
    var arr2 = ['red','green','yellow'];
    arr2[3] = 'blur';
    console.log(arr2);
    arr2[2] = 'black';/*这会替换原有的数组*/
    console.log(arr2);
</script>
<body>

</body>
</html>